<template>
<client-only>
  <div class="in-wrap">
    <!-- 公共头引入 -->
    <header id="header">
      <section class="container">
        <h1 id="logo">
          <a href="#" title="在线教育平台">
            <img src="~/assets/img/logo.png" style="position: relative; bottom:18px" width="96%" alt="在线教育平台">
          </a>
        </h1>
        <div class="h-r-nsl">
          <ul class="nav">
            <router-link to="/" tag="li" active-class="current" exact>
              <a>首页</a>
            </router-link>
            <router-link to="/course" tag="li" active-class="current">
              <a>课程</a>
            </router-link>
            <router-link to="/teacher" tag="li" active-class="current">
              <a>名师</a>
            </router-link>

            <router-link to="/qa" tag="li" active-class="current">
              <a>问答</a>
            </router-link>
          </ul>
          <!-- / nav -->
          <ul class="h-r-login">
            <li v-if="!loginInfo.id" id="no-login">
              <a href="/login" title="登录">
                <em class="icon18 login-icon">&nbsp;</em>
                <span class="vam ml5">登录</span>
              </a>
              |
              <a href="/register" title="注册">
                <span class="vam ml5">注册</span>
              </a>
            </li>
            <li v-if="loginInfo.id" id="is-login-one" class="mr10">
              <a id="headerMsgCountId" href="#" title="消息">
                <em class="icon18 news-icon">&nbsp;</em>
              </a>
              <q class="red-point" style="display: none">&nbsp;</q>
            </li>
            <li v-if="loginInfo.id" id="is-login-two" class="h-r-user">
              <a href="/ucenter" title>
                <img
                  :src="loginInfo.avatar"
                  width="30"
                  height="30"
                  class="vam picImg"
                  alt
                >
                <span id="userName" class="vam disIb">{{ loginInfo.nickname }}</span>
              </a>
              <a href="javascript:void(0);" title="退出" @click="logout()" class="ml5">退出</a>
            </li>
            <!-- /未登录显示第1 li；登录后显示第2，3 li -->
          </ul>
          <aside class="h-r-search">
            <form action="#" method="post">
              <label class="h-r-s-box">
                <input type="text" placeholder="输入你想学的课程" name="queryCourse.courseName" value>
                <button type="submit" class="s-btn">
                  <em class="icon18">&nbsp;</em>
                </button>
              </label>
            </form>
          </aside>
        </div>
        <aside class="mw-nav-btn">
          <div class="mw-nav-icon"></div>
        </aside>
        <div class="clear"></div>
      </section>
    </header>
    <!-- /公共头引入 -->

    <nuxt/>

    <!-- 公共底引入 -->
    <footer id="footer">
      <section class="container">
        <div class>
          <h4 class="hLh30">
            <span class="fsize18 f-fM c-999">友情链接</span>
          </h4>
          <ul class="of flink-list">
            <li>
              <a href="http://www.baidu.com/" title="百度" target="_blank">百度</a>
            </li>
            <li>
              <a href="https://www.bilibili.com/" title="哔哩哔哩" target="_blank">哔哩哔哩</a>
            </li>
          </ul>
          <div class="clear"></div>
        </div>
        <div class="b-foot">
          <section class="fl col-7">
            <section class="mr20">
              <section class="b-f-link">
                <a href="#" title="关于我们" target="_blank">关于我们</a>|
                <a href="#" title="联系我们" target="_blank">联系我们</a>|
                <a href="#" title="帮助中心" target="_blank">帮助中心</a>|
                <a href="#" title="资源下载" target="_blank">资源下载</a>|
              </section>
              <section class="b-f-link mt10">
                <span>©2023版权所有 京ICP备17055252号</span>
              </section>
            </section>
          </section>
          <aside class="fl col-3 tac mt15">
            <section class="gf-tx">
              <span>
                <img src="~/assets/img/wx-icon.png" alt>
              </span>
            </section>
            <section class="gf-tx">
              <span>
                <img src="~/assets/img/wb-icon.png" alt>
              </span>
            </section>
          </aside>
          <div class="clear"></div>
        </div>
      </section>
    </footer>
    <!-- /公共底引入 -->
  </div>
</client-only>
</template>
<script>
import '~/assets/css/reset.css'
import '~/assets/css/theme.css'
import '~/assets/css/global.css'
import '~/assets/css/web.css'
import '~/assets/css/base.css'
import '~/assets/css/activity_tab.css'
import '~/assets/css/bottom_rec.css'
import '~/assets/css/nice_select.css'
import '~/assets/css/order.css'
import '~/assets/css/swiper-3.3.1.min.css'
import "~/assets/css/pages-weixinpay.css"


import Cookies from 'js-cookie'


export default {
  data() {
    return {
      token: '',
      loginInfo: {
        id: '',
        age: '',
        avatar: '',
        mobile: '',
        nickname: '',
        sex: ''
      },
      notificationMessage: `<div style="font-family: Arial, sans-serif; line-height: 1.6;">
        <p><strong><font color="red">一、登录须知</font><strong><br> 
         1. 用户前台请访问：<br><font color="red">http://swordoffer.cn</font></p>
         2. 管理员页面请访问：<br><font color="red">https://manage.swordoffer.cn</font></p>
        <p><strong>二、页面卡顿</strong><br>
        前台使用nuxt.js编写，放在服务器加载较慢，若存在页面卡顿、资源不显示的现象，极有可能是服务器响应过慢的问题，请耐心等待或观看演示视频查看页面具体效果！<br>
        <p><strong>三、升级</strong><br>
        本项目仅为1.0版本，后面将持续升级！<br>
        <!-- 其他内容... -->
      </div>`
    }
  },

  created() {
    //获取路径里面的token值
    this.token = this.$route.query.token
    if (this.token) {//判断路径中是否有token值
      //this.wxLogin()
      return;
    }
    this.showInfo()
  },
  mounted(){
    this.open2()
  },
  methods: {
    open2() {
      this.$notify({
        title: '用户须知',
        message: this.notificationMessage,
        dangerouslyUseHTMLString: true, // 允许使用 HTML 格式的字符串
        duration: 2000
      });
    },
    //从cookie中获取用户信息
    showInfo() {
      //从cookie获取用户信息  cookie中存放的都是str
      let userStr = Cookies.get('userInfo')
      if (userStr == undefined || userStr == '') {
        this.loginInfo = {nickname: "游客"}
      } else {
        this.loginInfo = JSON.parse(String(userStr))
      }

    },
    //退出
    logout() {
      //清空cookie值
      Cookies.set('token', '', {domain: 'localhost'})
      Cookies.set('userInfo', '', {domain: 'localhost'})
      //回到首页面
      window.location.href = "/"
    }
  }
}
</script>
